<template>
  <Table :table-data="tableData" border
         :headerStyle="{backgroundColor:'#fffbed'}"
         :page="false"
         max-height="400px"
         :tableColumn="tableColumn">
  </Table>
</template>

<script>
import {rfcInfo} from '@/api/order'

export default {
  props: ['routesQuery'],
  data() {
    return {
      tableData: [],
      tableColumn: [
        {label: this.$t('税号'), align: 'center', prop: 'rfc'},
        {label: this.$t('姓名'), align: 'center', prop: 'rfcName'},
        {label: this.$t('证件编号'), align: 'center', prop: 'certificateNum'},
        {label: this.$t('有效性'), align: 'center', prop: 'isValid', isHtml: true},
      ]
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    async getList() {
      const {userId} = this.routesQuery
      const res = await rfcInfo({userId})
      if (res.code === 1 && res.data) {
        this.tableData = [{...res.data}].map(item => {
          item.isValid = item.isValid === 1 ? this.$t('有效') : item.isValid === 0 ? `<span style="color:red">${this.$t('无效')}</span>` : ''
          return item
        })
      }
    }
  }
}
</script>

<style scoped>

</style>
